from flask import Flask,render_template
from front.dish_type import bp as dish_type_bp
from front.desk import bp as desk_bp
from front.order import bp as order_bp
import config
from exts import db
from flask_migrate import Migrate
from model.models import Dish,DishType
import commands
from front.dish import bp as dish_bp

app = Flask(__name__)

# 注册蓝图
app.register_blueprint(dish_type_bp)
app.register_blueprint(dish_bp)
app.register_blueprint(desk_bp)
app.register_blueprint(order_bp)

app.config.from_object(config.DevelopmentConfig)

db.init_app(app)

# 数据库迁移对象
migrate = Migrate(app,db)

# 注册click指令
app.cli.command("create-dish_type")(commands.create_dish_type)
app.cli.command("create-dish")(commands.create_dish)
app.cli.command('create-desk')(commands.create_desk)

@app.route('/')
def hello_world():  # put application's code here
    return render_template("index.html")


if __name__ == '__main__':
    app.run()
